import Vue from 'vue'
import App from './App.vue'
import router from './router'
import 'lib-flexible/flexible'
import VueRouter from 'vue-router'
import axios from 'axios'
import VueAxios from 'vue-axios'

Vue.use(VueAxios, axios)
Vue.config.productionTip = false
import {
  Tabbar,
  NoticeBar,
  TabbarItem,
  Search,
  Tab,
  Tabs,
  Swipe,
  SwipeItem,
  List,
  PullRefresh,
  DropdownMenu,
  DropdownItem,
  Form,
  Field,
  Button,
  CellGroup,
  NavBar,
  Popup,
  IndexBar,
  IndexAnchor,
  Sticky,
  Cell,
  TreeSelect 
} from 'vant';
Vue.use(TreeSelect);
Vue.use(NoticeBar);
Vue.use(Cell);
Vue.use(Sticky);
Vue.use(IndexBar);
Vue.use(IndexAnchor);
Vue.use(Tabbar);
Vue.use(Button);
Vue.use(TabbarItem);
Vue.use(Search);
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(Swipe);
Vue.use(SwipeItem);
Vue.use(List);
Vue.use(PullRefresh);
Vue.use(DropdownMenu);
Vue.use(DropdownItem);
Vue.use(Form);
Vue.use(Field);
Vue.use(CellGroup);
Vue.use(NavBar);
Vue.use(Popup);
router.beforeEach((to, from, next) => {
  if (to.name === 'My'||to.name==='SelectSeat') {
    if (localStorage.getItem('Loginuser')) {
      next();
    } else {
      next({
        name: 'Login'
      });
    }
  } else {
    next();
  }

})
let originPush = VueRouter.prototype.push;

axios.defaults.baseURL = 'https://apis.netstart.cn/maoyan/';
//重新VueRouter的原型方法
VueRouter.prototype.push = function (location) {
  //location: 目标路由的信息
  originPush.call(this, location, () => {}, (err) => {
    // console.log('err ==> ', err);
  });
}
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')